package com.doone.telmarket.infrastructure.dao.impl;

import java.util.List;

import org.springframework.stereotype.Repository;

import com.doone.telmarket.domain.Service;
import com.doone.telmarket.domain.ServicePage;
import com.doone.telmarket.infrastructure.dao.BaseDaoSupport;
import com.doone.telmarket.infrastructure.dao.ServiceDAO;

/**
 * 
 * @author 吴同庆
 * @date 2009-9-15
 * @description 增值业务实体数据访问接口实现类
 * @package     com.doone.telmarket.infrastructure.dao.impl
 */
@Repository("serviceDAO")
public class ServiceDAOImpl extends BaseDaoSupport implements ServiceDAO {

	/**
	 * @package com.doone.telmarket.domain.ibator
	 * @author 甘雨波
	 * @description 根据ID获取增值业务
	 * @date 2009-9-23
	 */
	public Service selectServiceByPrimaryKey(String serviceCode) {
		Service service = (Service) getSqlMapClientTemplate().queryForObject("Service.selectByPrimaryKey", serviceCode);
		return service;
	}

	/**
	 * @package com.doone.telmarket.domain.ibator
	 * @author 甘雨波
	 * @description 保存增值业务
	 * @date 2009-9-23
	 */
	public Service insertService(Service service) {
		getSqlMapClientTemplate().insert("Service.insertService", service);
		 return service;
	}

	/**
	 * @package com.doone.telmarket.domain.ibator
	 * @author 甘雨波
	 * @description 根据增值业务类型获取增值业务
	 * @date 2009-9-23
	 */
	@SuppressWarnings("unchecked")
	public List<Service> getServiceList(Service service) {

		return getSqlMapClientTemplate().queryForList("Service.serlectServiceByType", service);
	}
	/**
	 * @package com.doone.telmarket.domain.ibator
	 * @author 甘雨波
	 * @description 根据ID删除增值业务
	 * @date 2009-9-23
	 */
	public int deleteServiceById(String id) {
		getSqlMapClientTemplate().delete("Service.deleteServicePage", id);
		return getSqlMapClientTemplate().delete("Service.ibatorgenerated_deleteByPrimaryKey", id);
	}

	/**
	 * @package com.doone.telmarket.domain.ibator
	 * @author 甘雨波
	 * @description 根据增值业务ID获取增值业务PAGEBEAN
	 * @date 2009-9-23
	 */
	public ServicePage selectServicePageByPrimaryKey(String serviceId) {
		return (ServicePage)getSqlMapClientTemplate().queryForObject("Service.selectServicePageByPrimaryKey", serviceId);
	}

	/**
	 * @package com.doone.telmarket.domain.ibator
	 * @author 甘雨波
	 * @description 保存增值业务PAGEBEAN
	 * @date 2009-9-23
	 */
	public void insertServicePage(ServicePage servicePage) {
		getSqlMapClientTemplate().insert("Service.insertServicePage", servicePage);
	}

	/**
	 * @package com.doone.telmarket.domain.ibator
	 * @author 甘雨波
	 * @description 更新增值业务
	 * @date 2009-9-23
	 */
	public void updateService(ServicePage servicePage) {
		Service service = servicePage.getService();
		getSqlMapClientTemplate().update("Service.updateService", service);
		getSqlMapClientTemplate().update("Service.updateServicePage", servicePage);
	}
}
